LGF_ActDeactDevice (FB / 2.0.0)

Overview

Author: Simatic Systems Support

Short description

LGF_ActDeactDevice implements a compact state machine to activate or deactivate a decentral device.

Block Interface

LGF_ActDeactDevice (FB)
Bool  deactivate done  Bool
    
Bool  activate busy  Bool
    
HW_DEVICE  hwId error  Bool
    
LGF_typeActDeactDeviceParameter  parameter status  Word
    
   deactivatingActive  Bool
    
   deactivatingDone  Bool
    
   activatingActive  Bool
    
   activatingDone  Bool
    
   diagnostics  LGF_typeDiagnostics
    
   

Input parameter

IdentifierData type Default value Description
deactivateBool FALSE Rising edge: Deactivate device given by `hwId`
activateBool FALSE Rising edge: Activate device given by `hwId`
hwIdHW_DEVICE --- Hardware ID of the device which should be activated / deactivated (`Device~PnIf~IODevice`)
parameterLGF_typeActDeactDeviceParameter --- Parameter dataset for the function `LGF_ActDeactDevice`

Output parameter

IdentifierData type Description
doneBool TRUE: Commanded functionality has been completed successfully
busyBool TRUE: FB is not finished and new output values can be expected
errorBool An error occurred during the execution of the FB
statusWord 16#0000 - 16#7FFF: Status of the FB, 16#8000 - 16#FFFF: Error identification
deactivatingActiveBool TRUE: Deactivating of device active
deactivatingDoneBool TRUE: Device deactivated
activatingActiveBool TRUE: Activation of device active
activatingDoneBool TRUE: Device activated
diagnosticsLGF_typeDiagnostics Diagnostic structure to store and transfer diagnostic information from blocks through the interface.

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_DEACTIVATION_DONE
Device deactivation done
16#0001STATUS_ACTIVATION_DONE
Device activation done
16#7000STATUS_NO_CALL
No job being currently processed
16#7040STATUS_DEACTIVATION
Processing device deactivation
16#7060STATUS_ACTIVATION
Processing device activation
16#8600ERR_UNDEFINED_STATE
Error: Due to an undefined state in state machine
16#8601ERR_LOG2GEO
Error: Log2Geo, may the HW ID for the device is wrong, please see `diagnostics.subFunctionStatus` for more detailed information
16#8602ERR_GEO2LOG
Error: Geo2Log, may the HW ID for the device is wrong, please see `diagnostics.subFunctionStatus` for more detailed information
16#8640ERR_DEVICE_DEACTIVATING
Error: Deactivation (D_ACT_DP) of device, please see `diagnostics.subFunctionStatus` for more detailed information
16#8641ERR_DEVICE_DEACTIVATING_TIME_OUT
Error: Deactivation of device - watchdog time expired
16#8642ERR_DEVICE_DEACTIVATING_RETRIES_REACHED
Error: Deactivation of device - max retries reached
16#8650ERR_READ_ACTIVATION_STATE_WHILE_DEACTIVATED
Error: Deactivation state (D_ACT_DP) of device is wrong, desired is `16#0000` or `16#0002`, please see `diagnostics.subFunctionStatus` for more detailed information
16#8660ERR_DEVICE_ACTIVATING
Error: Activation (D_ACT_DP) of device, please see `diagnostics.subFunctionStatus` for more detailed information
16#8661ERR_DEVICE_ACTIVATING_TIME_OUT
Error: Activation of device cause watchdog time expired. Can be a broken device connection
16#8662ERR_DEVICE_ACTIVATING_RETRIES_REACHED
Error: Activation of device cause max retries reached. Can be a broken device connection
16#8663ERR_READ_DEVICES_STATES_DURING_ACTIVATION
Error: Read Device states (`DeviceStates`) during device activation, please see `diagnostics.subFunctionStatus` for more detailed information
16#8670ERR_READ_DEVICES_STATES_WHILE_ACTIVE
Error: Read Device states (`DeviceStates`) while device active, please see `diagnostics.subFunctionStatus` for more detailed information
16#8671ERR_DEVICE_STATE_WHILE_ACTIVE
Error: Device states present error and is unreachable, faulty Device or IO-System
16#8672ERR_READ_ACTIVATION_STATE_WHILE_ACTIVE
Error: Activation state (`D_ACT_DP`) of device is wrong, desired is `16#0000` or `16#0001`, please see `diagnostics.subFunctionStatus` for more detailed information
16#8690ERR_DISABLING_DEACT_DEVICE
Error: Deactivation (D_ACT_DP) of device throws an error while disabling, please see `diagnostics.subFunctionStatus` for more detailed information
16#8691ERR_DISABLING_WATCHDOG
Error: Watchdog timer expired while disabling

User defined datatype(s)

LGF_typeActDeactDeviceParameter (UDT / V2.0.0)

This UDT belongs to the Module LGF_ActDeactDeviceParameter and lists all possible parameters to configure its behavior.

Identifier Data type Default value Description
activationRetries SInt 100 Number of activation & deactiviation retries until an error is set.
timeOutActDeact Time T#5S Time to monitor the commands `activate` and `deactivate`
should be greater than the configured `configuration time` in the PLC hardware configuration section `Startup`

LGF_typeDiagnostics (UDT / V1.0.1)

Diagnostic structure to store and transfer diagnostic information from blocks through the interface.

Identifier Data type Default value Description
status Word 16#0000 Status of the Block or error identification when error occurred
subfunctionStatus Word 16#0000 Status or return value of called FB's, FC's and system blocks
stateNumber DInt 0 State in the state machine of the block where the error occurred

Functional description

The module provides the procedure for activating and deactivating a remote IO-Device in the Profinet (PN, S7-1500 & S7-1200) and Profibus (DP, S7-1500) network.

The activation of the device (defined at hwId) is initiated by a rising edge at activate, after complete activation this is indicated at the output isActivated.


Note
The connection status of the decentralized device is as well displayed in the TIA Portal project navigation in the PLC, which is the controller, under the item 'Distributed I/O', if online with the engineering system.

Deactivation of the device (defined at hwId) is initiated by a rising edge at deactivate, after complete activation this is indicated at the output isDeactivated.


Note
The parameter timeOutActDeact for monitoring the activation and deactivation sequence should always be set higher than the parameterized value in the Device configuration / Startup / Configuration time.

Parameterization PLC

Change log

Version & DateChange description
1.0.0Simatic Systems Support
06.04.2024First released version in different project
2.0.0Simatic Systems Support
10.03.2025Refactoring & Improve Code for LGF Integration
Thats why we start here with V2.0 for the LGF integration
Copy of `LGF_ActDeactMonitorDevice` without device monitoring, just executing activation and deactivation